07 de Junio, 2017
ui <- fluidPage(
HTML("<h1>Título hecho con HTML</h1>")
)
server <- function(input, output) {}
shinyApp(ui, server)
ui <- fluidPage(
tags$h1("Título hecho con R")
)
server <- function(input, output) {}
shinyApp(ui, server)
tags: h1() - h6()
Tamaño del texto introducido
ui <- fluidPage(
h1("Tamaño 1"),
h2("Tamaño 2"),
h3("Tamaño 3"),
h4("Tamaño 4"),
h5("Tamaño 5"),
h6("Tamaño 6")
)
server <- function(input, output) {}
shinyApp(ui, server)
tags: hr()
Línea horizontal
ui <- fluidPage(
h3("texto"),
hr(),
h3("texto")
)
server <- function(input, output) {}
shinyApp(ui, server)
tags: "Texto"
Texto normal. El texto plano sin modificadores no necesita tags.
ui <- fluidPage(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua."
)
server <- function(input, output) {}
shinyApp(ui, server)
tags: br()
Salto de línea
ui <- fluidPage(
"Texto 1",
br(),
"Texto 2"
)
server <- function(input, output) {}
shinyApp(ui, server)
tags: p()
Párrafo
ui <- fluidPage(
p("Párrafo 1"),
p("Párrafo 2")
)
server <- function(input, output) {}
shinyApp(ui, server)
tags: em()
Letra en itálica/cursiva
ui <- fluidPage(
em("itálica")
)
server <- function(input, output) {}
shinyApp(ui, server)
tags: strong()
Letra en negrita
ui <- fluidPage(
strong("negrita")
)
server <- function(input, output) {}
shinyApp(ui, server)
tags: code()
Texto monoespaciado. Típicamente se emplea este comando para introducir código
ui <- fluidPage(
code("código")
)
server <- function(input, output) {}
shinyApp(ui, server)
Los tags se pueden anidar unos dentro de otros.
ui <- fluidPage(
p("Lorem ipsum dolor sit amet, ", strong("consectetur"), " adipiscing elit, ", em("sed eiusmod tempor incidunt ut labore et dolore magna aliqua."))
)
server <- function(input, output) {}
shinyApp(ui, server)
Las hojas de estilo en cascada (CSS) son un marco para personalizar la apariencia de elementos en una página web.
ui <- fluidPage(
theme = "bootstrap.css",
sidebarLayout(
sidebarPanel(),
mainPanel()
)
)
server <- function(input, output) {}
shinyApp(ui, server)
ui <- fluidPage(
includeCSS("bootstrap.css"),
sidebarLayout(
sidebarPanel(),
mainPanel()
)
)
server <- function(input, output) {}
shinyApp(ui, server)Extensiones de formato
Extensiones para cálculos/gráficos interactivos
library(shiny); library(shinythemes)
shinyApp(
ui = fluidPage(theme = shinytheme("cyborg"),
...
),
server = function(input, output) { }
)
87 widgets registrados actualmente (selección):
library(leaflet) leaflet() %>% addTiles() %>% addMarkers(lng=-0.3531, lat=39.4815, popup="FISABIO")
library(ggplot2, plotly) p <- ggplot(data = diamonds, aes(x = cut, fill = clarity)) + geom_bar(position = "dodge") ggplotly(p)
library(dygraphs)
lungDeaths <- cbind(ldeaths, mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
dyHighlight(highlightCircleSize = 5,
highlightSeriesBackgroundAlpha = 0.2,
hideOnMouseOut = FALSE)
library(networkD3) data(MisLinks, MisNodes) forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.4)
DT::datatable(iris, options = list(pageLength = 3, dom = "pt", language = list(url = '//cdn.datatables.net/plug-ins/1.10.11/i18n/Spanish.json')), rownames = FALSE, escape = FALSE)
library(d3heatmap) d3heatmap(mtcars, scale = "column", colors = "Spectral")
library(rgl); library(rglwidget); library(htmltools)
theta <- seq(0, 6*pi, len=100)
xyz <- cbind(sin(theta), cos(theta), theta)
lineid <- plot3d(xyz, type="l", alpha = 1:0, lwd = 5, col = "blue")["data"]
browsable(tagList(
rglwidget(elementId = "example", width = 500, height = 400,
controllers = "player"),
playwidget("example",
ageControl(births = theta, ages = c(0, 0, 1),
objids = lineid, alpha = c(0, 1, 0)),
start = 1, stop = 6*pi, step = 0.1,
rate = 6,elementId = "player")))
de forma local, con alguien que tiene R en su ordenador.
de forma global, con todo el mundo (sin necesidad de tener R).
runUrl( "<link a la web>")
runGitHub( "<nombre de tu repositorio>", "<tu nombre de usuario>")
Alojar tu app en tu repositorio libre de GitHub, manteniendo tu anonimato con Gist
runGist("código gist")
RStudio. 2016a. “Hoja de referencia de Shiny.” https://www.rstudio.com/wp-content/uploads/2015/03/shiny-spanish.pdf.
———. 2016b. “Shiny - Tutorial.” https://shiny.rstudio.com/tutorial/lesson1/.
RStudio Team. 2016. RStudio: Integrated Development Environment for R. Boston, MA: RStudio, Inc. http://www.rstudio.com/.
Shi, Kejia. 2017. “Leaflet Cheat Sheet: Leaflet for R.” https://github.com/rstudio/cheatsheets/raw/master/source/pdfs/leaflet cheat sheet.pdf.
Wickham, H. 2015. Advanced R. Boca Raton, FL: CRC.